#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 5000001;

int n,p,k;

void readNum(int &x){
    x = 0;
    int f = 1;
    char ch = getchar();
    while(!isdigit(ch)){
        if(ch=='-') f = -1;
        ch = getchar();
    }
    while(isdigit(ch)){
        x = (x<<3) + (x<<1) + (ch-'0');
        ch = getchar();
    }
    x *= f;
}
void readNum(LL &x){
    x = 0;
    int f = 1;
    char ch = getchar();
    while(!isdigit(ch)){
        if(ch=='-') f = -1;
        ch = getchar();
    }
    while(isdigit(ch)){
        x = (x<<3) + (x<<1) + (ch-'0');
        ch = getchar();
    }
    x *= f;
}

LL qpow(LL base,int n){
    LL res = 1;
    while(n){
        if(n&1){
            res = res*base%p;
        }
        base = base*base%p;
        n >>= 1;
    }
    return res;
}
LL arr[N];
LL ks[N];
LL brr[N];
LL ans = 0;

int main(){
    // scanf("%d%d%d",&n,&p,&k);
    readNum(n);
    readNum(p);
    readNum(k);
    for(int i=1;i<=n;i++){
        // scanf("%lld",&arr[i]);
        readNum(arr[i]);
    }
    ks[1] = k;
    brr[1] = qpow(arr[1],p-2);
    for(int i=2;i<=n;i++){
        ks[i] = ks[i-1]*k%p;
        brr[i] = qpow(arr[i],p-2);
    }
    for(int i=1;i<=n;i++){
        ans  = (ans+ks[i]*brr[i]%p)%p;
    }
    printf("%lld\n",ans);
    return 0;
}